import { TypeAppState, TypeStoryGroup } from './types'

const _g = [
	{ id: "chn", name: "中国", 'color': "#e74c3c" },
	{ id: "us", name: "美国", color: "#3498db" },
	{ id: "jp", name: "日本", color: "#9b59b6" },
	{ id: "zn", name: "新西兰", color: "#9b59b6" },
	{ id: "cb", name: "加拿大", color: "#9b59b6" },
	{ id: "xa", name: "西德", color: "#9b59b6" },
	{ id: "fr", name: "法国", color: "#9b59b6" },
	{ id: "ro", name: "罗马", color: "#9b59b6" },
	{ id: "il", name: "意大利", color: "#9b59b6" },
	{ id: "eu", name: "欧洲", color: "#f1c40f" }
];

const _data : TypeAppState = {
	title: '测试故事线',
	fileName: 'test1.sl',
	createdAt: new Date(),
	dateRange: {
		begin: 19450101,
		end: 20301231
	},
	groups: {},
	eventsCount: 100,
	pageIndex: 1,
	pageSize: 10,
	pageCount: 10,
	events: [],
	scrollTo: 10,
}

_g.forEach(g => {
	const { id, name, color } = g;
	_data.groups[g.id] = {
		id,
		title: name,
		styles: {
			// color
		}
	}
})

const _events = [
	{
		date: new Date(1945, 8, 2),
		originalDate: "1945-09-02",
		eraId: "ad",
		title: "日本签署投降书",
		groupId: "chn",
		content: "在东京湾的美国密苏里号战列舰上，日本政府代表签署投降书，标志着第二次世界大战正式结束。中国抗日战争胜利结束。",
		rawLine: 12
	},
	{
		date: new Date(1949, 9, 1),
		originalDate: "1949-10-01",
		eraId: "ad",
		title: "中华人民共和国成立",
		groupId: "chn",
		content: "毛泽东在天安门城楼上宣告中华人民共和国成立，标志着中国新民主主义革命的基本胜利。",
		rawLine: 15
	},
	{
		date: new Date(1969, 6, 20),
		originalDate: "1969-07-20",
		eraId: "ad",
		title: "阿波罗11号登月",
		groupId: "us",
		content: "美国宇航员尼尔·阿姆斯特朗和巴兹·奥尔德林成为首次登上月球的人类，实现了人类登月的梦想。",
		rawLine: 22
	},
	{
		date: new Date(1978, 11, 18),
		originalDate: "1978-12-18",
		eraId: "ad",
		title: "中国改革开放",
		groupId: "chn",
		content: "中国共产党十一届三中全会召开，确立了改革开放的基本国策，开启了中国经济快速发展的新时期。",
		rawLine: 28
	},
	{
		date: new Date(1989, 10, 9),
		originalDate: "1989-11-09",
		eraId: "ad",
		title: "柏林墙倒塌",
		groupId: "eu",
		content: "柏林墙被推倒，标志着冷战的结束和德国统一进程的开始，成为欧洲历史的重要转折点。",
		rawLine: 35
	},
	{
		date: new Date(1997, 5, 30),
		originalDate: "1997-06-30",
		eraId: "ad",
		title: "香港回归",
		groupId: "chn",
		content: "中华人民共和国政府恢复对香港行使主权，结束了英国在香港长达156年的殖民统治。",
		rawLine: 42
	},
	{
		date: new Date(2001, 8, 11),
		originalDate: "2001-09-11",
		eraId: "ad",
		title: "9·11恐怖袭击",
		groupId: "us",
		content: "恐怖分子劫持民航客机撞击美国纽约世界贸易中心和华盛顿五角大楼，造成近3000人死亡。",
		rawLine: 48
	},
	{
		date: new Date(2008, 7, 8),
		originalDate: "2008-08-08",
		eraId: "ad",
		title: "北京奥运会",
		groupId: "chn",
		content: "第29届夏季奥林匹克运动会在北京开幕，这是中国首次举办奥运会，展示了中国的综合国力。",
		rawLine: 55
	},
	{
		date: new Date(2011, 2, 11),
		originalDate: "2011-03-11",
		eraId: "ad",
		title: "东日本大地震",
		groupId: "jp",
		content: "日本东北地区发生9.0级地震并引发海啸，导致福岛核电站事故，是日本史上最严重的自然灾害之一。",
		rawLine: 62
	},
	{
		date: new Date(2016, 5, 23),
		originalDate: "2016-06-23",
		eraId: "ad",
		title: "英国脱欧公投",
		groupId: "eu",
		content: "英国举行全民公投，决定退出欧盟，这一决定对欧洲政治经济格局产生深远影响。",
		rawLine: 69
	},
	{
		date: new Date(2020, 0, 1),
		originalDate: "2020-01-01",
		eraId: "ad",
		title: "新冠疫情全球扩散",
		groupId: "chn",
		content: "新型冠状病毒开始在全球范围内传播，引发全球公共卫生危机，对世界经济和社会造成巨大冲击。",
		rawLine: 76
	},
	{
		date: new Date(2022, 1, 24),
		originalDate: "2022-02-24",
		eraId: "ad",
		title: "俄乌冲突爆发",
		groupId: "eu",
		content: "俄罗斯对乌克兰发起特别军事行动，引发二战以来欧洲最大规模的武装冲突，导致全球地缘政治格局剧变。",
		rawLine: 83
	},
	{
		date: new Date(2025, 0, 1),
		originalDate: "2025-01-01",
		eraId: "ad",
		title: "RCEP全面生效",
		groupId: "chn",
		content: "区域全面经济伙伴关系协定(RCEP)在15个成员国全面生效，形成全球最大自由贸易区，促进区域经济一体化。",
		rawLine: 90
	}
]


_events.forEach(e=>{
	const {originalDate, eraId, title, groupId, content} = e;
	
	
	_data.events.push({
		time: parseInt(originalDate.replaceAll('-', '')),
		timeText: originalDate,
		timeSystem: 'std',
		groupId: groupId,
		content: content,
		title: title,
		tags: ['测试', '123'],
		docPath: '',
		link:  Math.round(Math.random() *1000) % 7 == 0 ? ['https://baidu.com', 'file://baidu.com', 'htt://baidu.com']: []
	})
})


export const data = _data;

let once = false;
export function acquireVsCodeApi() {
	return {
		postMessage: function(evt) {
			if (!once) {
				console.log('mock msg')
				setTimeout(function() {
					window.postMessage({
						cmd: 'loaded',
						data: data
					})
				}, 500)
				once = true;
			}
		}
	}
}